<template>
  <el-dialog  class="dia-style" :title="title" :visible.sync="isOpen" width="60%" append-to-body>
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true">
      <el-form-item label="产品名称" prop="name">
        <el-input
          v-model="queryParams.name"
          placeholder="请输入产品名称"
          clearable
          style="width: 240px"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">查询</el-button>
      </el-form-item>
    </el-form>
    <el-table :data="tableList" style="max-height:300px;overflow:auto;">
      <el-table-column
        type="selection"
        width="55">
      </el-table-column>
      <el-table-column label="序号" align="center" width="120">
        <template slot-scope="scop">
          {{ scop.$index + 1 }}
        </template>
      </el-table-column>
      <el-table-column label="产品名称" prop="name" :show-overflow-tooltip="true"/>
      <el-table-column label="产品类型" prop="productName" :show-overflow-tooltip="true"/>
      <el-table-column label="接入厂商" prop="companyName" width="140"/>
      <el-table-column label="版本" align="center" prop="versionName" width="180">
      </el-table-column>
    </el-table>
    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <div slot="footer" class="dialog-footer">
      <el-button type="primary" @click="submitForm">保 存</el-button>
      <el-button @click="cancel">取 消</el-button>
    </div>
  </el-dialog>
</template>

<script>
//  模拟数据
import productTable from '@/views/accessProduct/mockData/productTable.json'


export default {
  name: 'selectDialog',
  props:{
    title:{
      type:String,
      default(){
        return '编辑'
      }
    },
    formData:{
      type:Object,
      default(){
        return {}
      }
    },
    open:{
      type:Boolean,
      default(){
        return false
      }
    }
  },
  data(){
    return {
      total:0,
      tableList:[],
      queryParams:{
        name:''
      },
      isOpen:this.open,

    }
  },
  watch:{
    open:{
      handler(newValue){
        this.isOpen=newValue;
      }
    }
  },
  mounted() {
    this.getList()
  },
  methods:{
    /** 查询角色列表 */
    getList() {
      this.loading = false
      this.tableList = productTable.data.list
      this.total = productTable.data.totalCount
    },
    /** 提交按钮 */
    submitForm: function() {
      this.$modal.msgSuccess('修改成功');
      this.isOpen = false
    },
    // 取消按钮
    cancel(){
      this.isOpen=false
    },

    /** 搜索按钮操作 */
    handleQuery() {
      this.loading = true
      let _self = this
      setTimeout(function() {
        _self.getList()
      }, 1000)
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const name = row.name
      this.$modal.confirm('是否确认删除角色编号为"' + name + '"的数据项？').then(function() {
        return true
      }).then(() => {
        this.getList()
        this.$modal.msgSuccess('删除成功')
      }).catch(() => {
      })
    },
  }
}
</script>

<style lang="scss" scoped>
.el-cascader{width:100%;}
</style>
